<%-- 
    Document   : Logout
    Created on : Apr 10, 2011, 3:21:15 PM
    Author     : Dawn
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<jsp:useBean id="users" class="Session.SessionKeeper" scope="session"></jsp:useBean>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta HTTP-EQUIV='REFRESH' content='3; url=index.jsp'>
        <title>Logout</title>
    </head>
    <body>
        <p>Logging out please wait...</p>

        <%
            Connection connection = null;

            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                }
            catch (ClassNotFoundException ex)
                {

            }
            connection = DriverManager.getConnection("jdbc:mysql://localhost/chatter?user=root&password=");

            Statement stm=null;
            stm=connection.createStatement();
            stm.execute("DELETE FROM onlineuser WHERE Username = '"+ users.getUsername() +"'");

            session.invalidate();
            users = null;
            stm.close();
            connection.close();
        %>
        
    </body>
</html>
